package Fourth;

public class Student implements Comparable{
    String name;
    int languageScore;
    int mathScore;
    int EnglishScore;
    int totalScore;

    public Student() {
    }

    public Student(String name, int languageScore, int mathScore, int englishScore) {
        this.name = name;
        this.languageScore = languageScore;
        this.mathScore = mathScore;
        EnglishScore = englishScore;
    }

    public void study(){
        System.out.println(this.name + "正在学习");
    }

    @Override
    public boolean equals(Object o){
        if(!(o instanceof Student student)){
            return false;
        }
        return student.totalScore == this.totalScore;
    }

    @Override
    public int compareTo(Object o) {
        if(!(o instanceof Student student)){
            return -1;
        }

        if(student.totalScore > this.totalScore){
            return 1;
        }else if (student.totalScore == this.totalScore){
            return 0;
        }else{
            return -1;
        }
    }
}
